﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20.状态模式
{
    class Program
    {
        static void Main(string[] args)
        {
            State s = new State();
            s.Say();
            s.Say();
            s.Say();
            Console.Read();
        }
    }
    public interface People
    {
        void Say(State s);
    }
    public class Chinese : People
    {
        public void Say(State s)
        {
            Console.Write("现在是中文...");
            s.people = new English();
            Console.WriteLine("现在切换到了英文");
        }
    }
    public class English : People
    {
        public void Say(State s)
        {
            Console.Write("现在是英文...");
            s.people = new Chinese();
            Console.WriteLine("现在切换到了中文");
        }
    }
    public class State
    {
        public People people { get; set; }
        public State()
        {
            people = new Chinese();
            Console.WriteLine("现在默认状态是中文");
        }
        public void Say()
        {
            people.Say(this);
        }
    }
 
}
